﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataConsistency.UC
{
    public partial class DoHoaMU : UserControl
    {
        public string BSImgPath = "C:\\cygwin\\usr\\local\\ns-allinone-2.31\\==Doc==\\Simulator\\DataConsistency\\DataConsistency\\images\\BS.png";
        public string MUImgPath = "C:\\cygwin\\usr\\local\\ns-allinone-2.31\\==Doc==\\Simulator\\DataConsistency\\DataConsistency\\images\\MU.png";
        
        // BS position
        private int _x;
        private int _y;
        public int X
        {
            get { return this._x; }
            set { this._x = value; }
        }

        public int Y
        {
            get { return this._y; }
            set { this._y = value; }
        }

        List<Init.MUNOde> listOfNode = new List<Init.MUNOde>();
        /// <summary>
        /// Lay danh sach MU node
        /// </summary>
        /// <param name="list"></param>
        public void getListOfNode(List<Init.MUNOde> list)
        {
            listOfNode = list;
        }

        public DoHoaMU()
        {
            InitializeComponent();
        }
        public void DoHoaMU_Load(object sender, EventArgs e)
        {
            
        }

        /// <summary>
        /// Ve BS Node
        /// </summary>
        /// <param name="g"></param>
        public void drawBS(Graphics g)
        {
            Bitmap bmp = new Bitmap(BSImgPath);
            bmp.MakeTransparent(Color.White);
            g.DrawImage(bmp, new Point(X, Y/2));
        }

        /// <summary>
        /// Ve Mobile Node
        /// </summary>
        /// <param name="g"></param>
        public void drawMU(Graphics g)
        {
            for (int i = 0; i < listOfNode.Count(); i++)
            {
                Init.MUNOde node = new Init.MUNOde();
                node = listOfNode[i];
                
                Bitmap bmp = new Bitmap(MUImgPath);
                bmp.MakeTransparent(Color.White);
                g.DrawImage(bmp, new Point((int)node.x, (int)node.y/2));
            }          

        }

        /// <summary>
        /// Ve len lop Do hoa
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DoHoaMU_Paint(object sender, PaintEventArgs e)
        {
            drawBS(e.Graphics);
            drawMU(e.Graphics);
        }

        private void DoHoaMU_MouseDown(object sender, MouseEventArgs e)
        {

        }
    }
}
